package com.longxi.tianjintianbao.ui.activity.approval;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.widget.Button;
import android.widget.LinearLayout;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.approval.ApprovalDetailAtPresenter;
import com.longxi.tianjintianbao.ui.view.approval.IApprovalDetailAtView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import butterknife.BindView;

public class ApprovalDetailActivity extends BaseActivity<IApprovalDetailAtView, ApprovalDetailAtPresenter> implements IApprovalDetailAtView {
    //审核
    @BindView(R.id.llAudit)
    LinearLayout mLlAudit;
    @BindView(R.id.btnReject)
    Button mBtnReject;
    @BindView(R.id.btnPass)
    Button mBtnPass;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_approval_detail;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.initAdapter();
    }

    @Override
    public void initListener() {
        super.initListener();
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                mPresenter.getTaskList();
            }
        });
        mPresenter.getTaskList();

        mBtnReject.setOnClickListener(v -> mPresenter.myApprovalSave("0"));
        mBtnPass.setOnClickListener(v -> mPresenter.myApprovalSave("1"));
    }

    @Override
    protected ApprovalDetailAtPresenter createPresenter() {
        return new ApprovalDetailAtPresenter(this);
    }

    @Override
    public SmartRefreshLayout getRefreshLayout() {
        return mRefreshLayout;
    }

    @Override
    public RecyclerView getRvContent() {
        return mRvContent;
    }

    @Override
    public LinearLayout getLlAudit() {
        return mLlAudit;
    }

    @Override
    public Button getBtnReject() {
        return mBtnReject;
    }

    @Override
    public Button getBtnPass() {
        return mBtnPass;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mPresenter.onActivityResult(requestCode, resultCode, data);
    }
}
